deno jupyter
denoでJupyter Lab
https://deno.com/blog/v1.37
要約
1. pip install jupyterlabでjupyterを入れる
python3が必要
2. deno jupyter --installでdeno jupyterをインストール
jupyter lab --kernel denoで起動
https://gyazo.com/97d27ff2614a0af1ceb2c6c60c29d47e
どうすればいいの...bsahd.icon
仕方なくawaitを使った
https://gyazo.com/9ab271289753015123d1dd662dfe08e6
https://gyazo.com/979e3b2b8eae85fdd4117f0de57ffc17で行けた
code:js
import pl from "npm:nodejs-polars";
import { display } from "https://deno.land/x/display@v1.1.1/mod.ts";
function convertStreamToString(readableStream: ReadableStream<Uint8Array>) {
const reader = readableStream
.pipeThrough(new TextDecoderStream())
.getReader();
let result = "";
function processText(
chunk: ReadableStreamReadResult<string>,
): Promise<string> {
if (chunk.done) {
return Promise.resolve(result);
}
result += chunk.value;
return reader.read().then(processText);
}
return reader.read().then(processText);
}
fetch("https://cdn.jsdelivr.net/npm/world-atlas@1/world/110m.tsv")
.then((response)=>{
console.log("connected")
return convertStreamToString(response.body);
}).then((data)=>{
console.log("full retrieved")
let df = pl.readCSV(data, { sep: "\t" });
display(df)
})
後続のセルをブロックしない
https://gyazo.com/909ca1098edd65767c97b455e822281f
awaitすると後続のセルをブロックするので遅いが、Jupyter的にはそっちがいいのかな